package handler

import (
	"context"
	"dubbo-go-app/api"
	"dubbo-go-app/pkg/global"
	"dubbo-go-app/pkg/model"
	"errors"
)

type GreeterServer struct {
	api.UnimplementedGreeterServer
}

// 绑定
var _ api.GreeterServer = &GreeterServer{}

func (g *GreeterServer) SqlRemove(ctx context.Context, request *api.SqlRequest) (*api.Activity, error) {
	if db := global.DB.Where("activity_id = ?", request.Id).Delete(&model.Activity{}); db.Error != nil {
		return nil, errors.New("not found activity")
	}
	return &api.Activity{Status: "ok"}, nil
}

func (g *GreeterServer) SqlRemoveStream(server api.Greeter_SqlRemoveStreamServer) error {
	//TODO implement me
	panic("implement me")
}
